import { defineStore } from 'pinia'
export const userStore = defineStore('user', {
    state: () => {
        return {
            token: null,
            name: 'visual'
        }
    },
    getters: {
        getName: state => {
            return state.name
        }
    },
    actions: {
        saveName(name) {
            this.name = name
        },
        getUser() {
            return new Promise(resolve => {
                setTimeout(() => {
                    resolve({
                        name: 'ww',
                        age: 30
                    })
                }, 2000)
            })
        },
        async setUser() {
            const result = await this.getUser()
            console.log(result)
        }
    }
})
